<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>学生选课管理系统</title></head>
<link rel="stylesheet" type="text/css" href="css/html.css">
<body>
<div id="app">
    <div class="header">
<!--        <img class="img" src="img/JK190120prj15120216786康正杰.png">-->
        <h2 class="site-title">
            <span class="logo">&sect;&prop;</span><span>学生选课管理系统-教师端</span></h2>
        <nav>
            <ul>
                <li v-for="(menu,index) in menus">
                    <a :key="menu.href" :class="{'active':active==index}" :key="menu.href" @click="active=index;currentSrc=menu.href">{{menu.text}}</a>
                </li>
            </ul>
        </nav>
        <div @click="active=6;currentSrc='teacher_info.html'" style="float:right">
            <span>工号：{{teacher.no}}</span>
            <span>姓名：{{teacher.name}}</span>
            <el-image :src="headImage" style="width: 45px;height: 45px;vertical-align:middle;"></el-image>
        </div >
    </div>
    <iframe class="main" name="content-frame" :src="currentSrc" width="100%" height="550px" ></iframe>
    <div class="footer"><p> &copy;Copyright JEE SWUST.</p></div>
</div>
<script src="../js/vue.js"></script>
<script src="../element-ui/lib/index.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<link rel="stylesheet" href="../element-ui/lib/theme-chalk/index.css">
<script>
    new Vue({
        el:"#app",
        data(){
            return{
                active:0,
                currentSrc:"home.html",
                menus:[
                    {text:"首页",href:"home.html"},
                    {text:"学院管理",href:"teacher_college.html"},
                    {text:"课程管理",href:"teacher_course.html"},
                    {text:"学生管理",href:"teacher_student.html"},
                    {text:"选课管理",href:"teacher_courseStudent.html"},
                    {text:"成绩管理",href:"teacher_score.html"},
                    {text:"个人信息",href:"teacher_info.html"}
                ],
                http_prefix:'http://localhost:8080/',
                config : {
                    headers: {'Content-Type': 'application/json;charset=UTF-8'}
                },
                headImage:'../img/default_head.png',
                teacher:{}
            }
        },
        methods:{
            hintMsg(msg) {
                this.$message(msg);
            },
            successMsg(msg) {
                this.$message({
                    message: msg,
                    type: 'success'
                });
            },
            warnMsg(msg) {
                this.$message({
                    message: msg,
                    type: 'warning'
                });
            },
            errorMsg(msg) {
                this.$message.error(msg);
            },
            getInfo()
            {
                axios.get(this.http_prefix+"teacher").then(resp=>{
                    if(resp.data.code!=1)
                    {
                        this.errorMsg(resp.data.msg);
                        return;
                    }
                    this.successMsg(resp.data.msg)
                    this.teacher=resp.data.data
                }).catch(err=>{
                        this.errorMsg(err.message)
                })
            },
            verify(){
                let userId=localStorage.getItem('userId')
                let role=localStorage.getItem('role')
                if(!userId||!role||role!='teacher')
                    window.location.href="index.html"
            },
            init(){
                    this.getInfo();
            }
        },
        mounted(){
            this.verify()
            this.init()
        }
    })
</script>
</body>
</html>